//
// Created by tonystark on 16/3/31.
// Copyright (c) 2016 sewm. All rights reserved.
//

#import "UIScrollView+ForceStop.h"


@implementation UIScrollView (ForceStop)


- (void)forceStopScrolling {
    CGPoint offset = self.contentOffset;
    //垂直方向的滚动
    if (offset.y + self.frameHeight > self.contentSize.height) {
        offset.y = self.contentSize.height - self.frameHeight;
    }
    if (offset.y < 0) {
        offset.y = 0;
    }
    //水平方向的滚动
    if (offset.x + self.frameWidth > self.contentSize.width) {
        offset.x = self.contentSize.width - self.frameWidth;
    }
    if (offset.x < 0) {
        offset.x = 0;
    }
    [self setContentOffset:offset animated:NO];
}


@end
